<!DOCTYPE html>
<html>
{include file="public/header" /}
<body>
<style>
    .layui-input-inline {
        width: 400px !important;
    }
</style>

<div class="layui-fluid" id="app">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">

                    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

                        <ul class="layui-tab-title">
                            <li onclick="go('index')">项目管理</li>
                            <li class="layui-this" onclick="location.reload()">编辑项目</li>
                        </ul>
                        <div class="layui-tab-content" style="padding-left: 0px;padding-right: 0px">
                            <div class="layui-tab-item layui-show" style="padding-top: 15px">
                                <form class="layui-form " action="">
                                    <input type="hidden" name="id" value="{$item.id}">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">户主</label>
                                        <div class="layui-input-block" style="padding: 5px 0px;">

                                              <span v-for="(item2,index) in set_client"
                                                    @click="delClient(index)"
                                                    class="layui-btn layui-btn-sm">{{item2.name}} <i
                                                      class="layui-icon">&#x1006;</i></span>


                                            <button type="button" id="client_btn"
                                                    class="layui-btn layui-btn-sm"
                                                    onclick="select_client()">
                                                +选择
                                            </button>
                                            </span>
                                        </div>


                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">城市</label>
                                        <div class="layui-input-block">
                                            <div style="float: left">
                                                <select name="sheng" lay-verify="required" id="sheng">
                                                    <option value="">请选择省</option>
                                                    <option value="河南省">河南省</option>
                                                </select>
                                            </div>
                                            <div style="float: left">
                                                <select name="shi" lay-verify="required" id="shi">
                                                    <option value="">请选择市</option>
                                                    <option value="周口市">周口市</option>
                                                </select>
                                            </div>
                                            <div style="float: left">
                                                <select name="xian" lay-verify="required" id="xian">
                                                    <option value="">请选择县\区</option>
                                                    <option value="川汇区">川汇区</option>
                                                    <option value="东新区">东新区</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">详细地址</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="address" value="{$item.address}"
                                                   class="layui-input" placeholder="请输入"
                                                   lay-verify="required">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div style="float: left" class="layui-col-md6">
                                            <label class="layui-form-label">面积</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="area" value="{$item.area}" class="layui-input"
                                                       placeholder="请输入"
                                                       lay-verify="required">
                                            </div>
                                        </div>
                                        <div style="float:left" class="layui-col-md6">
                                            <label class="layui-form-label">户型</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="house_type" value="{$item.house_type}"
                                                       class="layui-input" placeholder="请输入"
                                                       lay-verify="required">
                                            </div>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">开始时间</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input" id="time" name="start_time"
                                                   placeholder="请输入"
                                                   value="{$item.start_time}">
                                        </div>

                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">管理队伍</label>
                                        <div class="layui-input-block" style="padding: 5px 15px;">
                                            <span>
                                                <span>项目经理</span>
                                                <span style="margin-left: 10px"> {{project}}</span>
                                                <button type="button" class="layui-btn layui-btn-sm"
                                                        style="margin-left: 10px"
                                                        onclick="edit_select_pm()">
                                                    {{projectb}}
                                                </button>
                                            </span>
                                            <span style="margin-left: 10%">
                                                <span>客户经理</span>
                                                <span style="margin-left: 10px">{{customer}}</span>
                                                <button type="button" class="layui-btn layui-btn-sm"
                                                        style="margin-left: 10px"
                                                        onclick="edit_select_am()">
                                                    {{customerb}}
                                                </button>
                                            </span>
                                            <span style="margin-left: 10%">
                                                <span>设计师</span>
                                                <span style="margin-left: 10px">{{designer}}</span>
                                                <button type="button" class="layui-btn layui-btn-sm"
                                                        style="margin-left: 10px"
                                                        onclick="edit_select_ds()">
                                                    {{designerb}}
                                                </button>
                                            </span>
                                            <span style="margin-left: 10%">
                                                <span>质检</span>
                                                <span style="margin-left: 10px">{{quality}}</span>
                                                <button type="button" class="layui-btn layui-btn-sm"
                                                        style="margin-left: 10px"
                                                        onclick="edit_select_qc()">
                                                    {{qualityb}}
                                                </button>
                                            </span>

                                        </div>


                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">封面图片</label>

                                        <div class="layui-input-block " style="width: auto;">

                                            <div class="layui-upload-drag" id="pic1" style="padding: 2px">
                                                <img class="layui-upload-img"
                                                     style="width: 120px;height: 120px; object-fit: cover;"
                                                     src="{$item.project_picture2}">
                                                <input type="hidden" name="project_picture"
                                                       value="{$item.project_picture}"
                                                       lay-verify="required">
                                            </div>

                                        </div>
                                    </div>


                                    <div class="layui-form-item">
                                        <label class="layui-form-label">项目图纸</label>

                                        <div class="layui-input-block layui-row "
                                             style="display: inline-block;margin-left: 0px;width: 90%;">

                                            <div class="layui-col-xs2">
                                                <div class="layui-upload-drag upload_more" style="padding: 2px;">
                                                    <div style="margin-top: 5px;" class="layui-elip">
                                                        原始平面及建筑标记图
                                                    </div>
                                                    <img class="layui-upload-img"
                                                         style="width: 120px;height: 120px; object-fit: cover;"
                                                         src="{$qn_domain}/{$tuzhi.biaoji}?imageMogr2/auto-orient/thumbnail/!120x120r/gravity/Center/crop/120x120/quality/100/interlace/0">
                                                    <input type="hidden" name="tuzhi[biaoji]" value="{$tuzhi.biaoji}">
                                                </div>
                                            </div>

                                            <div class="layui-col-xs2">
                                                <div class="layui-upload-drag upload_more" style="padding: 2px;">
                                                    <div style="margin-top: 5px;" class="layui-elip">
                                                        原始尺寸测量图
                                                    </div>
                                                    <img class="layui-upload-img"
                                                         style="width: 120px;height: 120px; object-fit: cover;"
                                                         src="{$qn_domain}/{$tuzhi.celiang}?imageMogr2/auto-orient/thumbnail/!120x120r/gravity/Center/crop/120x120/quality/100/interlace/0">
                                                    <input type="hidden" name="tuzhi[celiang]" value="{$tuzhi.celiang}">
                                                </div>
                                            </div>

                                            <div class="layui-col-xs2">
                                                <div class="layui-upload-drag upload_more" style="padding: 2px;">
                                                    <div style="margin-top: 5px;" class="layui-elip">
                                                        墙体拆改图
                                                    </div>
                                                    <img class="layui-upload-img"
                                                         style="width: 120px;height: 120px; object-fit: cover;"

                                                         src="{$qn_domain}/{$tuzhi.chaigai}?imageMogr2/auto-orient/thumbnail/!120x120r/gravity/Center/crop/120x120/quality/100/interlace/0">
                                                    <input type="hidden" name="tuzhi[chaigai]" value="{$tuzhi.chaigai}">

                                                </div>
                                            </div>

                                            <div class="layui-col-xs2">
                                                <div class="layui-upload-drag upload_more" style="padding: 2px;">
                                                    <div style="margin-top: 5px;" class="layui-elip">
                                                        平面布局图
                                                    </div>
                                                    <img class="layui-upload-img"
                                                         style="width: 120px;height: 120px; object-fit: cover;"

                                                         src="{$qn_domain}/{$tuzhi.buju}?imageMogr2/auto-orient/thumbnail/!120x120r/gravity/Center/crop/120x120/quality/100/interlace/0">
                                                    <input type="hidden" name="tuzhi[buju]" value="{$tuzhi.buju}">


                                                </div>
                                            </div>

                                            <div class="layui-col-xs2">
                                                <div class="layui-upload-drag upload_more" style="padding: 2px;">
                                                    <div style="margin-top: 5px;" class="layui-elip">
                                                        地面材质示意图
                                                    </div>
                                                    <img class="layui-upload-img"
                                                         style="width: 120px;height: 120px; object-fit: cover;"


                                                         src="{$qn_domain}/{$tuzhi.shiyi}?imageMogr2/auto-orient/thumbnail/!120x120r/gravity/Center/crop/120x120/quality/100/interlace/0">
                                                    <input type="hidden" name="tuzhi[shiyi]" value="{$tuzhi.shiyi}">


                                                </div>
                                            </div>

                                            <div class="layui-col-xs2">
                                                <div class="layui-upload-drag upload_more" style="padding: 2px;">
                                                    <div style="margin-top: 5px;" class="layui-elip">
                                                        顶面天花布局图
                                                    </div>
                                                    <img class="layui-upload-img"
                                                         style="width: 120px;height: 120px; object-fit: cover;"

                                                    src="{$qn_domain}/{$tuzhi.dingmian}?imageMogr2/auto-orient/thumbnail/!120x120r/gravity/Center/crop/120x120/quality/100/interlace/0">
                                                    <input type="hidden" name="tuzhi[dingmian]" value="{$tuzhi.dingmian}">

                                                </div>
                                            </div>

                                            <div class="layui-col-xs2">
                                                <div class="layui-upload-drag upload_more" style="padding: 2px;">
                                                    <div style="margin-top: 5px;" class="layui-elip">
                                                        顶面天花尺寸图
                                                    </div>
                                                    <img class="layui-upload-img"
                                                         style="width: 120px;height: 120px; object-fit: cover;"


                                                    src="{$qn_domain}/{$tuzhi.dingmian_chichun}?imageMogr2/auto-orient/thumbnail/!120x120r/gravity/Center/crop/120x120/quality/100/interlace/0">
                                                    <input type="hidden" name="tuzhi[dingmian_chichun]" value="{$tuzhi.dingmian_chichun}">

                                                </div>
                                            </div>

                                            <div class="layui-col-xs2">
                                                <div class="layui-upload-drag upload_more" style="padding: 2px;">
                                                    <div style="margin-top: 5px;" class="layui-elip">
                                                        开关面板示意图
                                                    </div>
                                                    <img class="layui-upload-img"
                                                         style="width: 120px;height: 120px; object-fit: cover;"

                                                         src="{$qn_domain}/{$tuzhi.kaiguan}?imageMogr2/auto-orient/thumbnail/!120x120r/gravity/Center/crop/120x120/quality/100/interlace/0">
                                                    <input type="hidden" name="tuzhi[kaiguan]" value="{$tuzhi.kaiguan}">




                                                </div>
                                            </div>

                                            <div class="layui-col-xs2">
                                                <div class="layui-upload-drag upload_more" style="padding: 2px;">
                                                    <div style="margin-top: 5px;" class="layui-elip">
                                                        墙面装饰布局图
                                                    </div>
                                                    <img class="layui-upload-img"
                                                         style="width: 120px;height: 120px; object-fit: cover;"

                                                         src="{$qn_domain}/{$tuzhi.qiangmian}?imageMogr2/auto-orient/thumbnail/!120x120r/gravity/Center/crop/120x120/quality/100/interlace/0">
                                                    <input type="hidden" name="tuzhi[qiangmian]" value="{$tuzhi.qiangmian}">




                                                </div>
                                            </div>

                                            <div class="layui-col-xs2">
                                                <div class="layui-upload-drag upload_more" style="padding: 2px;">
                                                    <div style="margin-top: 5px;" class="layui-elip">
                                                        平面索引图
                                                    </div>
                                                    <img class="layui-upload-img"
                                                         style="width: 120px;height: 120px; object-fit: cover;"

                                                         src="{$qn_domain}/{$tuzhi.suoyin}?imageMogr2/auto-orient/thumbnail/!120x120r/gravity/Center/crop/120x120/quality/100/interlace/0">
                                                    <input type="hidden" name="tuzhi[suoyin]" value="{$tuzhi.suoyin}">



                                                </div>
                                            </div>

                                            <div class="layui-col-xs2">
                                                <div class="layui-upload-drag upload_more" style="padding: 2px;">
                                                    <div style="margin-top: 5px;" class="layui-elip">
                                                        立面图
                                                    </div>
                                                    <img class="layui-upload-img"
                                                         style="width: 120px;height: 120px; object-fit: cover;"

                                                         src="{$qn_domain}/{$tuzhi.limian}?imageMogr2/auto-orient/thumbnail/!120x120r/gravity/Center/crop/120x120/quality/100/interlace/0">
                                                    <input type="hidden" name="tuzhi[limian]" value="{$tuzhi.limian}">




                                                </div>
                                            </div>

                                            <div class="layui-col-xs2">
                                                <div class="layui-upload-drag upload_more" style="padding: 2px;">
                                                    <div style="margin-top: 5px;" class="layui-elip">
                                                        剖面图
                                                    </div>
                                                    <img class="layui-upload-img"
                                                         style="width: 120px;height: 120px; object-fit: cover;"



                                                    src="{$qn_domain}/{$tuzhi.paomian}?imageMogr2/auto-orient/thumbnail/!120x120r/gravity/Center/crop/120x120/quality/100/interlace/0">
                                                    <input type="hidden" name="tuzhi[paomian]" value="{$tuzhi.paomian}">

                                                </div>
                                            </div>


                                        </div>

                                    </div>


                                    <div class="layui-form-item form-footer2">
                                        <div class="layui-input-block">
                                            <button class="layui-btn" type="button" lay-submit
                                                    lay-filter="edit_project">立即提交
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
    var app = new Vue({
        el: '#app',
        data: {
            project: "",
            customer: "",
            quality: "",
            designer: "",
            projectb: "选择",
            customerb: "选择",
            designerb: "选择",
            qualityb: "选择",
            set_client: [],
        },
        methods: {
            delClient: function (index) {
                this.set_client.splice(index, 1);
            },
        },
    });
    function set_client(id, name) {
        var i = 0;
        app.set_client.forEach(function (item, index) {
            if (item.id == id) {
                i = 1;
            }
        });
        if (i == 0) {
            app.set_client.push({name: name, id: id});
        }
        else {
            layer.msg('请不要重复选择哟！');
        }
    }
    $(function () {
        var p = "";
        if ('{$p}') {
            p = '{$p}';
            var pm = eval('(' + p + ')');
            layui.data('epm', {
                key: 'epmList',
                value: pm
            });
        }

        var a = "";
        if ('{$a}') {
            a = '{$a}';
            var am = eval('(' + a + ')');
            layui.data('eam', {
                key: 'eamList',
                value: am
            });
        }

        var d = "";
        if ('{$d}') {
            d = '{$d}';
            var ds = eval('(' + d + ')');
            layui.data('eds', {
                key: 'edsList',
                value: ds
            });
        }

        var q = "";
        if ('{$q}') {
            q = '{$q}';
            var qc = eval('(' + q + ')');
            layui.data('eqc', {
                key: 'eqcList',
                value: qc
            });
        }
        var c = "";
        if ('{$c}') {
            c = '{$c}';
            var client = eval('(' + c + ')');
            app.set_client = client;
            console.log(client);
            console.log(app.set_client);
        }


    });
    app.project = "{$item.pm}";
    app.customer = "{$item.am}";
    app.quality = "{$item.qc}";
    app.designer = "{$item.ds}";
    layui.use(['form', 'upload', 'laydate'], function () {
        var $ = layui.$
            , layer = layui.layer
            , form = layui.form;
        var upload = layui.upload;
        var laydate = layui.laydate;
        //网站设置
        //监听submit提交

        form.on('submit(edit_project)', function (obj) {
            var localPm = layui.data('epm');
            var localAm = layui.data('eam');
            var localDs = layui.data('eds');
            var localQc = layui.data('eqc');
            if (app.set_client.length == 0) {
                layer.msg('户主不能为空！');
                return false;
            }
            if (jQuery.isEmptyObject(localPm.epmList)) {
                layer.msg('项目经理不能为空！');
                return false;
            }
            if (jQuery.isEmptyObject(localAm.eamList)) {
                layer.msg('客户经理不能为空！');
                return false;
            }
            if (jQuery.isEmptyObject(localDs.edsList)) {
                layer.msg('设计师不能为空！');
                return false;
            }
            if (jQuery.isEmptyObject(localQc.eqcList)) {
                layer.msg('质检不能为空！');
                return false;
            }
            obj.field['client'] = app.set_client;
            obj.field['prom'] = localPm.epmList;
            obj.field['cusm'] = localAm.eamList;
            obj.field['quli'] = localQc.eqcList;
            obj.field['des'] = localDs.edsList;
//            layer.msg(JSON.stringify(obj.field)); obj.field为当前容器的全部表单字段，名值对形式：{name: value}
            $.post("{:url('edit_project')}", obj.field, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg, {icon: 1})
                    layui.data('epm', null);
                    layui.data('eam', null);
                    layui.data('eds', null);
                    layui.data('eqc', null);
                    return false;
                } else {
                    layer.msg(res.msg, {icon: 2})
                    return false;
                }

            });
            return false;
        });


        //同时绑定多个元素，并将属性设定在元素上
        upload.render({
            elem: '.upload_more'
            , url: '/tool/qiniu/upload'
            , before: function () {
                layer.tips('上传中...', this.item, {tips: 1});
            }
            , done: function (res, index, upload) {
                var item = this.item;
                layer.tips('上传中完成', this.item, {tips: 1});
                console.log(item); //获取当前触发上传的元素，layui 2.1.0 新增
                $(item).find('img').attr('src', res.data.url);
                $(item).find('input').val(res.data.pic);
            }
        })


        //拖拽上传
        upload.render({
            elem: '#pic1'
            , url: '/tool/qiniu/upload'
            , before: function () {
                layer.load(2);
            }
            , done: function (res) {
                layer.closeAll();
                console.log(res)
                $('#pic1 img').attr('src', res.data.url);//完整url
                $('#pic1 input').val(res.data.pic);//存入数据库中的部分url
            }
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#time' //指定元素
        });
    });
    function edit_select_pm() {
        var id = "{$Request.param.id}";
        layer.open({
            type: 2,
            title: '项目经理',
            shadeClose: true,
            shade: 0.01,
            area: ['50%', '90%'],
            content: "{:url('edit_select_pm')}?id=" + id
        });
    }
    function edit_select_am() {
        var id = "{$Request.param.id}";
        layer.open({
            type: 2,
            title: '客户经理',
            shadeClose: true,
            shade: 0.01,
            area: ['50%', '90%'],
            content: "{:url('edit_select_am')}?id=" + id
        });
    }
    function edit_select_ds() {
        var id = "{$Request.param.id}";
        layer.open({
            type: 2,
            title: '设计师',
            shadeClose: true,
            shade: 0.01,
            area: ['50%', '90%'],
            content: "{:url('edit_select_ds')}?id=" + id
        });
    }
    function edit_select_qc() {
        var id = "{$Request.param.id}";
        layer.open({
            type: 2,
            title: '质检',
            shadeClose: true,
            shade: 0.01,
            area: ['50%', '90%'],
            content: "{:url('select_qc')}?id=" + id
        });
    }
    function select_client() {
        layer.open({
            type: 2,
            title: '户主',
            shadeClose: true,
            shade: 0.01,
            area: ['60%', '90%'],
            content: "{:url('select_client')}",
        });
    }
</script>

<script>
    //设置选择状态
    function setSelect(ele, val) {

        $('#' + ele + ' option').each(function (index, ele) {
            var el = $(ele);
            if (el.attr('value') == val) {
                el.attr('selected', 'selected')
            } else {
                el.removeAttr('selected');
            }
        })

    }

    $(function () {
        setSelect('sheng', "{$item.sheng}")
        setSelect('shi', "{$item.shi}")
        setSelect('xian', "{$item.xian}")
    });


</script>
</body>
</html>